var submit = $("#submit");
submit.click(function () {
    var goods_name = $("#goods_name").val();
    var price = $("#goods_price").val();
    var goods_id = $("#goods_id").val();
    var de = $(".delete");
    $.ajax({
        url:'/administrator/addUser',
        type:"GET",
        dataType:"JSON",
        data:{
            goodsName:goods_name,
            storeId:goods_id,
            goodsPrice:price,
        },
        success:function (data) {
            if(data.msg.code==100){
                location.reload();
            }
        }
    });
    var de = $(".delete");
    for(var i=0;i<de.length;i++){
        $(de[i]).click(function () {
            var tr = $(this).parent().parent();
            tr.remove();
            var value = $(this).data('id');
            console.log(value);
            $.ajax({
                url:'/administrator/deleteUser',
                type:"GET",
                dataType:"JSON",
                data:{
                    userId:value
                },
                success:function(data){
                    if(data.msg.code==100){
                        location.reload();
                    }
                }
            });
        });
    }
});

//页面删除
var de = $(".delete");
for(var i=0;i<de.length;i++){
    $(de[i]).click(function () {
        var tr = $(this).parent().parent();
        tr.remove();
        var value = $(this).data('id');
        console.log(value);
        $.ajax({
            url:'/administrator/deleteUser',
            type:"GET",
            dataType:"JSON",
            data:{
                userId:value
            },
            success:function(data){
                if(data.msg.code==100){
                    location.reload();
                }
            }
        });
    });
}

//编辑
$(".style_img").click(function () {
    $(".shadow").hide();
})
$(".style_close").click(function(){
    $(".shadow").hide();
})

$(".style_replace").click(function(){
    var   value = $(this).data('id');
    console.log(value);

    $(".style_submit").click(function () {
        console.log(value);
        var conName = $("#conName").val();
        var comPrice = $("#comPrice").val();
        console.log(conName);
        console.log(comPrice);
        $.ajax({
            url:'/administrator/upGoodsDate',
            type:"GET",
            dataType:"JSON",
            data:{
                id:value,
                goodsName:conName,
                goodsPrice:comPrice
            },
            success:function(date){
                if(date.code==100){
                    alert("修改成功！");
                    location.reload();
                    $(".shadow").hide();
                }
                else {
                    alert("修改失败！")
                }
            }
        })

    })


    $(".shadow").toggle();
})








